package ipad.asia.service.evaluate;

import ipad.asia.entity.Evaluate;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.time.LocalDateTime;
import java.util.List;
@Component
@FeignClient(value = "PROVIDER-CHAT")
public interface EvaluateFeign {
    /**查看消费者顾客的评价*/
    @RequestMapping("/evaluate/getByConsumerName")
     List<Evaluate> findByConsumerName(@RequestParam(value = "consumerName") String consumerName);
    /**查看商家的评价*/
    @RequestMapping("/evaluate/getByShopId")  //方便测试
     List<Evaluate> findByShopId(@RequestParam(value = "shopId") int shopId);
    /**根基评价找人或商家或发评价的人*/
    @RequestMapping("/evaluate/getById")
     Evaluate findById(@RequestParam(value = "id") int id);
//    /**发布评价*/
//    @RequestMapping("/evaluate/launch")
//     void launch(@RequestParam(value = "consumerId") int consumerId,
//                       @RequestParam(value = "shopId") int shopId,
//                       @RequestParam(value = "content",required = false) String content,
//                       @RequestParam(value = "level",required = false) Integer level,
//                       @RequestParam(value = "date") LocalDateTime date);
    /**修改的评价,只能修改一次，修改后chance变为1,返回值为true表示可修改，返回值为发；false表示已经修改过改评论*/
    @RequestMapping("/evaluate/update")
     boolean update(@RequestParam(value = "id") int id,
                          @RequestParam(value = "content",required = false) String content,
                          @RequestParam(value = "level",required = false) Integer level,
                          @RequestParam(value = "date") LocalDateTime date,
                          @RequestParam(value = "chance") Integer chance);

    /**发布评价*/
    @RequestMapping("/evaluate/launch")
     void launch(@RequestParam(value = "consumerName") String consumerName,
                       @RequestParam(value = "shopId") int shopId,
                       @RequestParam(value = "productId") int productId,
                       @RequestParam(value = "orderId") int orderId,
                       @RequestParam(value = "content",required = false) String content,
                       @RequestParam(value = "level",required = false) Integer level,
                       @RequestParam(value = "date") LocalDateTime date);


    @RequestMapping("/evaluate/findByProductId")
     List<Evaluate> findByProductId(@RequestParam(value = "productId")int productId);
    @RequestMapping("/evaluate/findByOrderId")
     Evaluate findByOrderId(@RequestParam(value = "orderId",required = false) int orderId);
}
